void cat()
{
open2();
read2();
}

void read2()
{
    int i, start, num, inum;
for(i = 0; i < FILENUM; i++)
if((file_array[i].inum > 0) &&
!strcmp(file_array[i].file_name,argv[1]))
break;
inum = file_array[i].inum;
read_blk(inum);
for(i = 0; (i < inode_array[inum].length) && (temp[i] != '\0'); i++)
printf("%c", temp[0+i]);
printf("\n");
}

void open2()
{
int i, inum, mode, filenum,chk;
if(argc==2)
{
for(i = 0; i < INODENUM; i++)
if((inode_array[i].inum > 0) &&
(inode_array[i].type == '-') &&
!strcmp(inode_array[i].file_name,argv[1]))
break;
if(i == INODENUM)
{
printf("The file you want to open doesn't exsited.\n");
return ;
}
inum = i;
chk=check(i);
if(chk!=1)
{
printf("This file is not your !\n");
return ;
}
for(i = 0; i < FILENUM; i++)
if(file_array[i].inum < 0) break;
if(i == FILENUM)
{
printf("The file table is full, please close some file.\n");
return ;
}
filenum = i;
file_array[filenum].inum = inum;
strcpy(file_array[filenum].file_name, inode_array[inum].file_name);
file_array[filenum].mode = 3;
file_array[filenum].offset = 0;
}
else if(argc==4)
{
    for(i = 0; i < INODENUM; i++)
if((inode_array[i].inum > 0) &&
(inode_array[i].type == '-') &&
!strcmp(inode_array[i].file_name,argv[3]))
break;
if(i == INODENUM)
{
printf("The file you want to open doesn't exsited.\n");
return ;
}
inum = i;
chk=check(i);
if(chk!=1)
{
printf("This file is not your !\n");
return ;
}
for(i = 0; i < FILENUM; i++)
if(file_array[i].inum < 0) break;
if(i == FILENUM)
{
printf("The file table is full, please close some file.\n");
return ;
}
filenum = i;
file_array[filenum].inum = inum;
strcpy(file_array[filenum].file_name, inode_array[inum].file_name);
file_array[filenum].mode = 3;
file_array[filenum].offset = 0;

}
else{
    printf("error");
    return ;
}

}

/*void write2()
{
int i, inum, length;
for(i = 0; i < FILENUM; i++)
if((file_array[i].inum>0)&&
!strcmp(file_array[i].file_name,argv[3])) break;
inum = file_array[i].inum;
if(inode_array[inum].length == 0)
{
//length=argv[1].length();
gets(temp);
if((length < 0) && (length >1024))
{
printf("Input wrong.\n");
return ;
}
inode_array[inum].length = length;
inode_array[inum].address[0] = get_blknum();
if(length > 512)
inode_array[inum].address[1] = get_blknum();
save_inode(inum);
temp=argv[1];
write_blk(inum);
}
else
printf("This file can't be written.\n");
}
*/